﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="材料出库红票.aspx.cs" Inherits="syc.Store.材料出库红票" %>
<html>
<head>
<title></title>
<style>
div.AutoComplete_Container{position:absolute; z-index:2;border:solid 1px #dd3333;background-color:#ffffff;padding:1px;font-size:14px;color:#ff0000;}
#AutoComplete_CurrentLine{ background-color:#0000cc;}
tr.AutoComplete_Row{font-size:14px;color:#6f320a;height:18px;cursor:pointer;}
tr.AutoComplete_HotRow{font-size:14px;color:#6f320a; background-color:#ffee88;height:18px;cursor:pointer;}
</style>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:HiddenField ID="LeiBie" runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="SELECT @材料ID=t1.材料ID,@单位ID=t1.单位ID
,@数量0=t1.数量0,@数量=t1.数量,@单价=t1.单价,@日期=t1.日期
,@备注=t1.备注,@单据号=t1.单据号
,@品名=t2.品名,@规格=t2.规格,@单位=t2.单位
,@单位名称=t3.名称
FROM 材料入出库 t1
left outer join 物料品种 t2 on t2.ID=t1.材料ID
left outer join 材料供货单位 t3 on t3.ID=t1.单位ID where t1.ID=@ID and t1.入出=3;"

UpdateCommand="update 材料入出库 set 单位ID=@单位ID,日期=@日期,单据号=@单据号,备注=@备注 where ID=@ID;"
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    oninserted="SqlDataSource1_Inserted" onselected="SqlDataSource1_Selected" 
    onupdated="SqlDataSource1_Updated" >
<SelectParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" DefaultValue="0" />
<asp:Parameter Name="材料ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="单位ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="数量0" DbType="Double" Size="9" Direction="Output" />
<asp:Parameter Name="数量" DbType="Double" Size="9" Direction="Output" />
<asp:Parameter Name="单价" DbType="Double" Size="13" Direction="Output" />
<asp:Parameter Name="日期" DbType="Date" Size="3" Direction="Output" />
<asp:Parameter Name="备注" DbType="String"  Size="100" Direction="Output" />
<asp:Parameter Name="品名" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="规格" DbType="String"  Size="40" Direction="Output" />
<asp:Parameter Name="单位" DbType="String"  Size="20" Direction="Output" />

<asp:Parameter Name="单位名称" DbType="String" Size="40" Direction="Output" />
<asp:Parameter Name="单据号" DbType="Int32" Size="4" Direction="Output"/>
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" Direction="Output" />
<asp:ControlParameter Name="材料ID" DbType="Int32" Size="4" ControlID="LeiBie"/>
<asp:ControlParameter Name="单位ID" DbType="Int32" Size="4" ControlID="FenChang"/>
<asp:ControlParameter Name="数量0" DbType="Decimal" Size="9" ControlID="ShuLiang"/>
<asp:ControlParameter Name="数量" DbType="Decimal" Size="9" ControlID="ShuLiang"/>
<asp:ControlParameter Name="单价" DbType="Decimal" Size="13" ControlID="DanJia"/>
<asp:ControlParameter Name="日期" DbType="Date" Size="3" ControlID="Date1"/>
<asp:ControlParameter Name="单据号" DbType="Int32" Size="4" ControlID="DanHao"/>
<asp:ControlParameter Name="备注" DbType="String"  Size="100" ControlID="BeiZhu"/>
<asp:Parameter Name="保管员" DbType="String" Size="20" />
</InsertParameters>
<UpdateParameters>
<asp:ControlParameter Name="ID" DbType="Int32" Size="4" ControlID="Label_ID"/>
<asp:ControlParameter Name="单位ID" DbType="Int32" Size="4" ControlID="FenChang"/>
<asp:ControlParameter Name="日期" DbType="Date" Size="3" ControlID="Date1"/>
<asp:ControlParameter Name="单据号" DbType="Int32" Size="4" ControlID="DanHao"/>
<asp:ControlParameter Name="备注" DbType="String"  Size="100" ControlID="BeiZhu"/>
</UpdateParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select 0 as ID,'' as 名称 union all select ID, 名称 FROM 材料供货单位"></asp:SqlDataSource>

<asp:Label ID="Label_ID" runat="server" Text="0" Visible="false"></asp:Label>

<div id="wintop" class="wintop" style="display:none;">材料出库红票</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <asp:Button ID="Button_Save" runat="server" Text="保 存" UseSubmitBehavior="false"
            CssClass="button" onclick="Button_Save_Click"  />
    <asp:Button ID="Button_Close" runat="server" Text="关 闭" UseSubmitBehavior="false"  Visible="true"
            CssClass="button" OnClientClick="parent.swin2_close();return false;" />
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel">

物料：<asp:TextBox ID="WuLiao" runat="server" CssClass="textbox" Width="105px"></asp:TextBox>
    
<span style="margin-left:10px;"></span>数量：<asp:TextBox ID="ShuLiang" runat="server" CssClass="textbox" Width="100px"></asp:TextBox>
<span style="margin-left:10px;"></span>单价：<asp:TextBox ID="DanJia" runat="server" CssClass="textbox" Width="100px"></asp:TextBox>

<span style="margin-left:10px;"></span>使用单位：<asp:DropDownList ID="FenChang" Width="120px"
    runat="server">
    <asp:ListItem Text="" Value="0"></asp:ListItem>
    <asp:ListItem Text="一分厂" Value="1"></asp:ListItem>
    <asp:ListItem Text="二分厂" Value="2"></asp:ListItem>
    <asp:ListItem Text="三分厂" Value="3"></asp:ListItem>
    <asp:ListItem Text="四分厂" Value="4"></asp:ListItem>
    <asp:ListItem Text="五分厂" Value="5"></asp:ListItem>
</asp:DropDownList>

<div style="font-size:6px;line-height:6px;height:6px;"></div>

日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin-left:10px;"></span></span>单号(No)：<asp:TextBox ID="DanHao" runat="server" CssClass="textbox" Width="80px"></asp:TextBox>
<span style="margin-left:10px;"></span></span>备注：<asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="296px"></asp:TextBox>
</asp:Panel>

<asp:Panel ID="Panel3" runat="server" CssClass="panel3">

<script>putBillHead();</script>
<style>
td.bb{border:0.5pt solid #000000;text-align:center;}
#GuiGe{display:none;}
#DanWei{display:none;}
#BianHao{display:none;}
span{color:Red;}
#Label_BeiZhu{color:Red;}
</style>
<table border="0" cellpadding="0" style="border-collapse: collapse;font-size:14px;">
<tr>
<td colspan="7" style="font-size:24px;height:36px;" align="center"><b>材 料 出 库 单</b></td>
</tr>
<tr>
<td colspan="3" height="24">编码：SYC/ZJ-WL-01</td>
<td colspan="4" align="right" style="font-size:16px;">No.<span id="Label_DanHao"></span></td>
</tr>
<tr>
<td colspan="2" height="24">使用单位：<span id="Label_FenChang"></span></td>
<td colspan="3"><span id="Label_Date1"></span></td>
<td colspan="2">类别：<asp:Label ID="Label_LeiBie" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td class="bb" rowspan="2" height="48">材料名称</td>
<td class="bb" rowspan="2">规格及材质</td>
<td class="bb" rowspan="2">单位</td>
<td class="bb" colspan="2">数量</td>
<td class="bb" colspan="2">价格</td>
</tr>
<tr>
<td class="bb">应发</td>
<td class="bb">实发</td>
<td class="bb">单价</td>
<td class="bb">金额</td>
</tr>
<tr>
<td class="bb" height="30"width="130" ><asp:Label ID="Label_PinMing" runat="server" Text=""></asp:Label></td>
<td class="bb" width="130"><asp:Label ID="Label_GuiGe" runat="server" Text=""></asp:Label></td>
<td class="bb" width="60"><asp:Label ID="Label_DanWei" runat="server" Text=""></asp:Label></td>
<td class="bb" width="70"><span id="Label_ShuLiang0"></span></td>
<td class="bb" width="70"><span id="Label_ShuLiang"></span></td>
<td class="bb" width="85"><span id="Label_DanJia"></span></td>
<td class="bb" width="85"><span id="Label_JinE"></span></td>
</tr>
<tr>
<td class="bb" height="40">备注</td>
<td class="bb" width="490" colspan="6" style="text-align:left;"><div id="Label_BeiZhu" style="display:block;"></div></td>
</tr>
<tr>
<td height="24">主管：</td>
<td colspan="2">发料：</td>
<td colspan="2">领料主管：</td>
<td colspan="2">　　领料：</td>
</tr>
</table>
<script>    putBillFoot();</script>
</asp:Panel>

</form>
<script >
    var notice = "<%=this.Notice %>";
    if (notice != "") {
        parent.showmsgbox(notice);
    }
</script>
<script >
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "textbox") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.id == "BeiZhu") return;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT" || tag.tagName == "DIV") {
            if (e.keyCode == 13) {
                e.keyCode = 9;
            }
        }
        else if (e.keyCode == 8) {
            return false;
        }
    }
    document.getElementById("FenChang").onchange = function() {
        document.getElementById("Label_FenChang").innerHTML = this.options[this.selectedIndex].text;
    };

    document.getElementById("ShuLiang").onchange = function() {
        document.getElementById("Label_ShuLiang0").innerHTML = this.value;
        document.getElementById("Label_ShuLiang").innerHTML = this.value;
        document.getElementById("Label_JinE").innerHTML = fixFloat(this.value * document.getElementById("DanJia").value, 2);
    };
    document.getElementById("DanJia").onchange = function() {
        document.getElementById("Label_DanJia").innerHTML = this.value;
        document.getElementById("Label_JinE").innerHTML = fixFloat(this.value * document.getElementById("ShuLiang").value,2);
    };
    document.getElementById("Date1").onchange = function() {
        document.getElementById("Label_Date1").innerHTML = this.value;
    };
    document.getElementById("DanHao").onchange = function() {
        document.getElementById("Label_DanHao").innerHTML = "0000000".substr(this.value.length) + this.value;
    };
    document.getElementById("BeiZhu").onchange = function() {
        document.getElementById("Label_BeiZhu").innerHTML = this.value;
    };
    document.getElementById("FenChang").onchange();
    document.getElementById("ShuLiang").onchange();
    document.getElementById("DanJia").onchange();
    
    document.getElementById("Date1").onchange();
    document.getElementById("DanHao").onchange();
    document.getElementById("BeiZhu").onchange();


    var WuLiao = document.getElementById("WuLiao");
    var LeiBie = document.getElementById("LeiBie");
    var Label_LeiBie = document.getElementById("Label_LeiBie");
    var Label_PinMing = document.getElementById("Label_PinMing");
    var Label_GuiGe = document.getElementById("Label_GuiGe");
    var Label_DanWei = document.getElementById("Label_DanWei");
    var Label_BianHao = document.getElementById("Label_BianHao");


    //自动完成
    var AutoComplete_Container = document.getElementById("AutoComplete_Container");
    if (!AutoComplete_Container) {//创建容器
        AutoComplete_Container = document.createElement("DIV");
        AutoComplete_Container.id = "AutoComplete_Container";
        AutoComplete_Container.className = "AutoComplete_Container";
        AutoComplete_Container.style.display = "none";
        document.body.appendChild(AutoComplete_Container);
    }
    var AutoComplete_Lists = new Array();
    var AutoComplete_Target = null;
    var AutoComplete_LastValue = "";
    function AutoComplete_SetHotRow(o) {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        hotrow.id = "";
        hotrow.className = "AutoComplete_Row";
        o.id = "AutoComplete_HotRow";
        o.className = "AutoComplete_HotRow";
    }
    function AutoComplete_Select() {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        if (hotrow) {
            var li = AutoComplete_Lists[hotrow.rowIndex].split("\t");

            Label_LeiBie.innerHTML = li[0];
            Label_PinMing.innerHTML = li[1];
            Label_GuiGe.innerHTML = li[2];
            Label_DanWei.innerHTML = li[3];

            //AutoComplete_Target.value = li[0];
            LeiBie.value = li[0];
        }
    }
    function AutoComplete_Response(http) {
        if (http.status != 200) {
            alert("服务器错误: " + http.status + " " + http.statusText);
            return;
        }
        if (http.responseText == "") {
            AutoComplete_Container.innerHTML = "<div style=padding:3px;font-size:14px;>没有查询到您录入的品种</div>";
        }
        else {
            var className = "AutoComplete_HotRow";
            var rs = http.responseText.split("\n");
            var tmp = "<table>";
            var cs;
            var id = " id=AutoComplete_HotRow";
            for (var i = 0; i < rs.length - 1; i++) {
                AutoComplete_Lists[i] = rs[i];
                cs = rs[i].split("\t");
                tmp += "<tr" + id + " class=" + className + " onmousemove=AutoComplete_SetHotRow(this); onmousedown=AutoComplete_Select();><td style='width:90px;padding:1px 2px 0px 2px;'>"
                    + cs[0] + "</td><td align=center style=width:120px>"
                    + cs[1] + "</td><td align=center style=width:120px>"
                    + cs[2] + "</td><td align=center style=width:80px>"
                    + cs[4] + "/" + cs[3] + "</td></tr>";
                className = "AutoComplete_Row";
                id = "";
            }
            tmp += "</table>";
            AutoComplete_Container.innerHTML = tmp;
        }

        AutoComplete_Container.style.display = "";
        AutoComplete_Container.style.top = (getObjectTop(AutoComplete_Target) + AutoComplete_Target.clientHeight + 2) + "px";
        AutoComplete_Container.style.left = (getObjectLeft(AutoComplete_Target)) + "px";
    };
    function AutoComplete_HideContainer() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
    }
    function AutoComplete_SetValue(value) {
        if (typeof (AutoComplete_Target.value) != "undefined") AutoComplete_Target.value = value;
        else if (typeof (AutoComplete_Target.innerText) != "undefined") AutoComplete_Target.innerText = value;
        else if (typeof (AutoComplete_Target.textContent) != "undefined") AutoComplete_Target.textContent = value;
    }
    function AutoComplete() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
        else if (AutoComplete_Target != document.activeElement) {
            AutoComplete_Target = null;
            setTimeout("AutoComplete_HideContainer()", 100);
        }
        else {
            var txt;
            if (typeof (AutoComplete_Target.value) != "undefined") txt = AutoComplete_Target.value;
            else if (typeof (AutoComplete_Target.innerText) != "undefined") txt = AutoComplete_Target.innerText;
            else if (typeof (AutoComplete_Target.textContent) != "undefined") txt = AutoComplete_Target.textContent;

            txt = txt.replace(/^\s+/, '').replace(/\s+$/, '');
            if (txt == "") {
                AutoComplete_Container.style.display = "none";
            }
            else if (txt != AutoComplete_LastValue) {
                AutoComplete_LastValue = txt;
                var request = createRequest(AutoComplete_Response);
                request.open("GET", encodeURI("/Store/物料品种查询.ashx?s=" + txt), true);
                request.send(null);
            }
        }
        setTimeout("AutoComplete()", 200);
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;

        if (tag == AutoComplete_Target && AutoComplete_Container.style.display != "none") {
            if (e.keyCode != 9) {
                Label_LeiBie.innerHTML = "";
                Label_PinMing.innerHTML = "";
                Label_GuiGe.innerHTML = "";
                Label_DanWei.innerHTML = "";
            }
            if (e.keyCode == 38) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex > 0) {
                        lt.rows[hotrow.rowIndex - 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex - 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[lt.rows.length - 1].id = "AutoComplete_HotRow";
                        lt.rows[lt.rows.length - 1].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 40) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex < lt.rows.length - 1) {
                        lt.rows[hotrow.rowIndex + 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex + 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[0].id = "AutoComplete_HotRow";
                        lt.rows[0].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 13) {
                AutoComplete_Select();
                e.keyCode = 9;
            }
            else if (e.keyCode == 27) {
                AutoComplete_LastValue = "";
                tag.value = "";
            }
        }
        else if (e.keyCode == 13) {
            e.keyCode = 9;
        }

    }
    setTimeout("AutoComplete()", 200);
    //自动完成结束
    document.getElementById("WuLiao").onfocus = function() {
        AutoComplete_LastValue = "";
        AutoComplete_Target = this;
        this.select();
    }
    
    
</script>
</body>
</html>
